<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit, Vue.prototype.$vFN.Mixins.Page, Vue.prototype.$vFN.Mixins.Table],
  components: {},
  data() {
    return {
      appWindow: window,
      apiUrl: {
        list: "plugin/team-dividend/admin/casher/page",
        delete: "plugin/team-dividend/admin/casher/destroy",
      },
      form: {
        // 设置的数据
        ratio: 0,
        switch: 0,
      },

      load: true,
    };
  },
  methods: {
    async sum() {
      console.log(this.form.ratio);
      let res = await this.$vFN.Http.post({
        url: "plugin/team-dividend/admin/casher/setting/setBase",
        data: {
          switch: this.form.switch,
          ratio: this.form.ratio,
        }
      }, window);
      if(res.code == 200) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.getData();
        this.mixinTable_refreshData();
      }
    },
    // 
    async getData() {
      let res = await this.$vFN.Http.post({
        url: "plugin/team-dividend/admin/casher/setting/getBase",
      }, window);
      this.form.ratio = res.data.ratio;
      this.form.switch = res.data.switch;
    },

    async del(_id) {
      let res = await this.$vFN.Http.post({
        url: this.apiUrl.delete,
        data: {
          casher_desk_id: _id,
        }
      }, window);
      if(res.code == 200) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.mixinTable_refreshData();
      }
    },
    
    // 修改
    editBoxOpen(params_) {
      Edit.init({
        editType: params_.type,
        id: params_.id,
        ratio: params_.ratio,
        onSuccess: () => {
          this.mixinTable_refreshData();
        }
      })
    },
    // 初始化
    async init() {
      this.getData();
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>